package org.polyforms.di.intercept;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.polyforms.di.util.DefaultValue;

/**
 * {@link MethodInterceptor} for methods which annotated by {@link org.polyforms.di.annotation.NoOperation}.
 * 
 * It does nothing in execution, and the return value depends the return type of method, which is null for object types
 * and default value of fields in class for primitive types.
 * 
 * @author Kuisong Tong
 * @since 1.0
 */
public final class NoOperationInterceptor implements MethodInterceptor {

    /**
     * {@inheritDoc}
     */
    public Object invoke(final MethodInvocation invocation) {
        return DefaultValue.get(invocation.getMethod().getReturnType());
    }
}
